package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

type Person struct {
	ID   int    `uri:"id" binding:"required"`
	Name string `uri:"name" binding:"required"`
}

func main() {
	r := gin.Default()

	r.GET("/:name/:id", func(c *gin.Context) {
		var person Person
		if err := c.ShouldBindUri(&person); err != nil {
			c.JSON(http.StatusNotFound, gin.H{
				"msg": "参数错误",
			})
			return
		}

		c.JSON(http.StatusNotFound, person)
	})

	r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
